
import { Linking, TouchableOpacity, TouchableOpacityProps } from "react-native"

interface LinkProps extends TouchableOpacityProps {
    url: string
}

export const toLink = (url: string) => Linking.openURL(url)

export function Link(props: LinkProps) {
    const { children, url } = props
    
    const openUrl = async () => {
        await Linking.openURL(url)
    }
    
    return <TouchableOpacity onPress={openUrl}>{children}</TouchableOpacity>
}